package com.acwing.partition19;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/4/19 8:58
 */
public class AC1883删减 {

    private static StreamTokenizer tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    private static PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String s = next(), t = next();
        StringBuilder sb = new StringBuilder();
        int n = s.length(), m = t.length();
        for (int i = 0; i < n; i++) {
            sb.append(s.charAt(i));
            if (sb.length() >= m && sb.substring(sb.length() - m, sb.length()).equals(t)) {
                sb.delete(sb.length() - m, sb.length());
            }
        }
        writer.println(sb);
        writer.flush();
    }

    private static String next() throws IOException {
        tokenizer.nextToken();
        return tokenizer.sval;
    }
}
